Socket
Socket
Sign inDemoInstall

ahocorasick

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ahocorasick

Implementation of the Aho-Corasick string searching algorithm, as described in the paper "Efficient string matching: an aid to bibliographic search".


Version published
Maintainers
1
Created

What is ahocorasick?

The ahocorasick npm package is an implementation of the Aho-Corasick algorithm, which is used for searching multiple keywords in a text simultaneously. It is particularly useful for tasks that involve pattern matching, such as text search, spam filtering, and DNA sequence analysis.

What are ahocorasick's main functionalities?

Keyword Initialization

This feature allows you to initialize the Aho-Corasick automaton with a list of keywords. The automaton will then be able to search for these keywords in any given text.

const AhoCorasick = require('ahocorasick');
const ac = new AhoCorasick(['he', 'she', 'his', 'hers']);

Search Text

This feature allows you to search a given text for the initialized keywords. The search method returns an array of matches, where each match includes the keyword and its position in the text.

const AhoCorasick = require('ahocorasick');
const ac = new AhoCorasick(['he', 'she', 'his', 'hers']);
const results = ac.search('ushers');
console.log(results);

Add Keywords

This feature allows you to add more keywords to the Aho-Corasick automaton after it has been initialized. This is useful if you need to dynamically update the list of keywords.

const AhoCorasick = require('ahocorasick');
const ac = new AhoCorasick(['he', 'she']);
ac.add('his');
ac.add('hers');

Other packages similar to ahocorasick

Keywords

FAQs

Package last updated on 12 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc